package ltd.dujiabao.orderservice.config;

import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.autoconfigure.amqp.RabbitTemplateConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Bowie Du
 * @date 2025/7/12 15:16
 */

@Configuration
public class RabbitConfig {
    @Bean
    public RabbitTemplate outboxRabbitTemplate(RabbitTemplateConfigurer configurer, ConnectionFactory connectionFactory,
                                               OutboxMessageCallback callback) {
        RabbitTemplate template = new RabbitTemplate();
        template.setConfirmCallback(callback);
        template.setReturnsCallback(callback);
        configurer.configure(template, connectionFactory);
        return template;
    }
}
